package editAir.buildEdit
{
	import _Pan3D.core.MathCore;
	
	import _me.Scene_data;
	
	import com.adobe.utils.PerspectiveMatrix3D;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display3D.Context3D;
	import flash.display3D.Context3DBlendFactor;
	import flash.display3D.Context3DCompareMode;
	import flash.display3D.Context3DProgramType;
	import flash.display3D.Context3DTextureFormat;
	import flash.display3D.Context3DTriangleFace;
	
	import newPan3d.content.build.BuildLevel;
	import newPan3d.content.frie.FrieLevel;
	import newPan3d.content.glass.GlassLevel;
	import newPan3d.content.ground.GroundLevel;
	import newPan3d.content.ground.groundUp.GroundUpLevel;
	import newPan3d.content.jineng.HuoqiuLevel;
	import newPan3d.content.lightScene.LightMenager;
	import newPan3d.content.npc.NpcLevel;
	import newPan3d.content.role.HeroLevle;
	import newPan3d.content.scene.SceneLevel;
	import newPan3d.content.scene.SceneMenager;
	import newPan3d.content.skill.SkillLevel;
	import newPan3d.content.tree.TreeLevel;
	import newPan3d.content.tree.luoye.LuoYeLevel;
	import editAir.water.WaterLevel;
	
	
	public class EditSceneLevel extends SceneLevel
	{
		[Embed(source="../_File/beijing1/panpanpan.jpg")]
		private static var newDengGuang:Class;
		public function EditSceneLevel()
		{
			super();
		}
		override public function makeScene():void
		{
			_groundView=new GroundLevel();
			_groundUpLevel=new GroundUpLevel()
			_buildView=new BuildLevel();
			_treeLevel=new TreeLevel();
			_glassLevel=new GlassLevel();
			_frieLevel=new FrieLevel();
			_heorLevle=new HeroLevle();
			_npcLevel=new NpcLevel();
			_luoYeLevel=new LuoYeLevel();
			_lightMenager=new LightMenager();
			_huoqiuLevel=new HuoqiuLevel();
			_skillLevel = new SkillLevel();
			_waterLevel = new WaterLevel();
			
			makeShenduText();
		}
		private  function makeShenduText():void
		{
			
			//初始化地面环境光贴图
			var context3D:Context3D=Scene_data.context3D
			var tempBmp:BitmapData=Bitmap(new newDengGuang()).bitmapData;
			//Scene_data.shenduText=context3D.createTexture(tempBmp.width,tempBmp.height, Context3DTextureFormat.BGRA,true);
			//Scene_data.shenduText.uploadFromBitmapData(tempBmp);

		}
	
		override public function upData():void
		{
			if (!Scene_data.ready)
				return;
			
			//Scene_data.focus3D.angle_x=-90;
			
			var lookAt:Boolean=false
			_lightMenager.updata(lookAt);
			if(lookAt){
				return;
			}
			var context3D:Context3D=Scene_data.context3D;
			
			MathCore._catch_cam(Scene_data.cam3D, Scene_data.focus3D);
			context3D.clear(0, 0, 0, 1);
			_projMatrix=new PerspectiveMatrix3D();
			_projMatrix.perspectiveFieldOfViewLH(1, 1, 0.1, 9000);
			context3D.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, _projMatrix, true);
			context3D.setBlendFactors(Context3DBlendFactor.ONE, Context3DBlendFactor.ZERO);
			context3D.setDepthTest(true, Context3DCompareMode.LESS);
			//_groundView.upData();
			context3D.setDepthTest(true, Context3DCompareMode.ALWAYS);
			//_groundUpLevel.upData();
			context3D.setDepthTest(true, Context3DCompareMode.LESS);
			_buildView.upData();
			_treeLevel.upData();
			_heorLevle.upData();
			_glassLevel.upData();
			_npcLevel.upData();
			
			//_luoYeLevel.upData();
			
			context3D.setCulling(Context3DTriangleFace.NONE);
			context3D.setBlendFactors(Context3DBlendFactor.SOURCE_ALPHA, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA);
			context3D.setDepthTest(false, Context3DCompareMode.LESS);
			//_huoqiuLevel.upData();
			_frieLevel.upData();
			_waterLevel.upData();
			
			context3D.present();
			SceneMenager.makelight3D();
			
			
			
		}
	}
}